/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.concurrent.TimeUnit;

/**
 * <p>Project: javaseapp - TtDemo
 * <p>Powered by webrx On 2021-08-24 08:45:29
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 16
 */
public class TtDemo {
    public static void main(String[] args) {
        //线程一
        var t1 = new T1();
        t1.setName("第一线程：");
        t1.start();

        //线程二
        var t2 = new Thread(new T2(), "第二线程：");
        t2.setName("d2：");
        t2.start();

        //主线程
        Thread.currentThread().setName("主线程：");
        String name = Thread.currentThread().getName();
        for (int i = 0; i < 10; i++) {
            try {
                TimeUnit.SECONDS.sleep(1);
            } catch (Exception e) {
                e.printStackTrace();
            }
            System.out.printf("%s = %d%n", name, i + 1);
        }


    }
}
